package ent

import (
	"elegantGo/chapter17/oo"
)

func (entArticleOrder *ArticleOrder) Mapper() oo.ArticleOrder {
	if entArticleOrder == nil {
		return nil
	}

	ooArticleOrder := oo.NewArticleOrder()
	ooArticleOrder.SetID(entArticleOrder.ID)
	ooArticleOrder.SetUserID(entArticleOrder.UserID)
	ooArticleOrder.SetArticleID(entArticleOrder.ArticleID)
	ooArticleOrder.SetPrice(entArticleOrder.Price)
	return ooArticleOrder
}

func (entArticleOrders ArticleOrders) Mapper() oo.ArticleOrders {
	size := len(entArticleOrders)
	ooArticleOrders := make(oo.ArticleOrders, size)
	for i := 0; i < size; i++ {
		ooArticleOrders[i] = entArticleOrders[i].Mapper()
	}
	return ooArticleOrders
}
